%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'structure');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');


%Make connection to database.  Note that the password has been omitted.
%Using JDBC driver.
conn = database('geomag', 'root', 'iwtlnk', 'Vendor', 'MYSQL', 'Server', '173.194.106.119', 'PortNumber', 3306);

%Read data from database.
curs = exec(conn, ['SELECT 	second_data.station_code'...
    ' ,	second_data.obsTime'...
    ' ,	second_data.elem_X'...
    ' ,	second_data.elem_Y'...
    ' ,	second_data.elem_Z'...
    ' ,	second_data.elem_F'...
    ' FROM 	geomdb_tsu.second_data  WHERE second_data.station_code = ' '''IPM''' ...
    ' ORDER by second_data.obsTime']);

curs = fetch(curs);
close(curs);

%Assign data to output variable
untitled = curs.Data;

%Close database connection.
close(conn);

%Clear variables
clear curs conn